# -*- coding: utf-8 -*-
# @Time     : 2021/11/30 10:27
# @Author   : wljess
# @File     : join同步阻塞02.py
# @Describe : 
# @Software : PyCharm

import time
import random
from multiprocessing import Process


def send(num):
    time.sleep(random.randint(1, 10))
    print(f"发送了第{num}份邮件")


if __name__ == '__main__':
    lst_p = []
    for i in range(10):
        p = Process(target=send, args=(i,))
        p.start()  # 异步非阻塞
        lst_p.append(p)

    for p in lst_p:
        p.join()  # 同步阻塞  直到p对应的进程结束之后才结束阻塞
    # 所有子进程都结束后要执行的代码
    print("10封邮件邮件已发送完毕...")
